package 上课day1;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;


public class project_demo01 {
	public static void main(String[] args) {
		ArrayList<Student> arrayList1 = new ArrayList<>();
		ArrayList<Student> arrayList2 = new ArrayList<>();
		
		
		Student stu1 = new Student(11, "张三");
		Student stu2 = new Student(12, "李四");
		Student stu3 = new Student(13, "王五");
		Student stu4 = new Student(14, "刘柳");
		Student stu5 = new Student(15, "李琦");
		
		Student stu6 = new Student(16, "王八");
		
		arrayList1.add(stu1);
		arrayList1.add(stu2);
		arrayList1.add(stu3);
		arrayList1.add(stu4);
		arrayList1.add(stu5);
		
		arrayList2.add(stu1);
		arrayList2.add(stu2);
		arrayList2.add(stu6);

		arrayList1.removeAll(arrayList2);
		
		arrayList1.addAll(arrayList2);
		
		// get遍历
		for (int i = 0; i < arrayList1.size(); i++) {
			Student student = arrayList1.get(i);
			System.out.println(student.getName() + "*************" + student.getAge());
		}
		
		System.out.println("-------------------------------------------------------");
		// Iterator
		Iterator<Student> iterator = arrayList1.iterator();
		while (iterator.hasNext()) {
			Student student = iterator.next();
			System.out.println(student.getName() + "*************" + student.getAge());
		}
		
	}
}
